<?php

function borrarImagenes($id_animal, $conexion){
	$query_img = "SELECT * FROM imagenes_animales WHERE id_animal = '$id_animal' AND imgagen_ppal = 0";
	$img = mysqli_query($conexion, $query_img)  or die(mysqli_error());

	while ($row_img = mysqli_fetch_assoc($img)) {
		unlink($row_img['ruta_img']);
	}

	$borrar_img = "DELETE FROM imagenes_animales WHERE id_animal = '$id_animal' AND imgagen_ppal = 0";
	mysqli_query($conexion, $borrar_img)  or die(mysqli_error());

}

?>